home *** CD-ROM | disk | FTP | other *** search
/ MacHack 1996 / MacHack 1996.toast / Hacks / Hacks ’92 / PowerBook Pixels™ 1.0.1 / ShotDetector / Darker.c < prev   
Encoding:
Text File  |  1992-06-17  |  1.3 KB  |  74 lines  |  [TEXT/KAHL]

  1. //
  2. // © 1992 Jon Wätte
  3. // PowerBook screen tester
  4. //
  5.  
  6.  
  7. #define FOOLED_YA 1
  8.  
  9. void
  10. main ( void )
  11. {
  12.     GrafPtr p ;
  13.     WindowPtr wp = NULL ;
  14.     Rect r ;
  15.     EventRecord er ;
  16.     RgnHandle rh ;
  17. #ifdef FOOLED_YA
  18.     int i ;
  19.     long keys [ 4 ] ; // 128 bits
  20.     Boolean flag = 0 ;
  21. #endif
  22.  
  23.     InitGraf ( & qd . thePort ) ;
  24.     InitFonts ( ) ;
  25.     InitWindows ( ) ;
  26.     TEInit ( ) ;
  27.     InitMenus ( ) ;
  28.     InitDialogs ( NULL ) ;
  29.  
  30.     r = ( * ( GetGrayRgn ( ) ) ) -> rgnBBox ;
  31.     r . top -= GetMBarHeight ( ) ;
  32.     wp = GetNewWindow ( 128 , NULL , NULL ) ;
  33.     SizeWindow ( wp , r . right - r . left , r . bottom - r . top , 0 ) ;
  34.     MoveWindow ( wp , r . left , r . top , 0 ) ;
  35.     SelectWindow ( wp ) ;
  36.     ShowWindow ( wp ) ;
  37.     rh = NewRgn ( ) ;
  38.     GetCWMgrPort ( & p ) ;
  39.     SetPort ( p ) ;
  40.     GetClip ( rh ) ;
  41.     ClipRect ( & r ) ;
  42.     PaintRect ( & r ) ;
  43.     HideCursor ( ) ;
  44.  
  45. #ifdef FOOLED_YA
  46.  
  47.     GetKeys ( & keys ) ;
  48.     if ( keys [ 1 ] & 0x4 ) { // Option key
  49.  
  50.         PenMode ( patXor ) ;
  51.         qd . randSeed = TickCount ( ) ;
  52.         for ( i = 0 ; i < 5 ; i ++ ) {
  53.  
  54.             MoveTo ( ( Random ( ) & 0x7fff ) % r . right ,
  55.                 ( Random ( ) & 0x7fff ) % r . bottom ) ;
  56.             Line ( 0 , 0 ) ;
  57.         }
  58.     }
  59. #endif
  60.  
  61.     SetClip ( rh ) ;
  62.     SetPort ( wp ) ;
  63.     ValidRect ( & r ) ;
  64.  
  65.     do {
  66.  
  67.         WaitNextEvent ( -1 , & er , 0x7fffffff , NULL ) ;
  68.  
  69.     } while ( er . what != mouseDown && er . what != keyDown ) ;
  70.     ShowCursor ( ) ;
  71.     DrawMenuBar ( ) ;
  72. }
  73.  
  74.